<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
if(isset($_GET['prod']) && $_GET['prod']!=""&& $_GET['type']!="")
{
$sqlSelImg="SELECT * FROM tbl_product_images WHERE product_id=".$_GET['prod']." and product_type='".$_GET['type']."'";
$rstSelImg=mysql_query($sqlSelImg);
$rowSelImg=mysql_fetch_array($rstSelImg);
$productImage1=$rowSelImg['product_image_1'];	
$productImage2=$rowSelImg['product_image_2'];
$productImage3=$rowSelImg['product_image_3'];
$productImage4=$rowSelImg['product_image_4'];
$productImage5=$rowSelImg['product_image_5'];
$productThumbnail1=$rowSelImg['product_thumbnail_1'];
$productThumbnail2=$rowSelImg['product_thumbnail_2'];
$productThumbnail3=$rowSelImg['product_thumbnail_3'];
$productThumbnail4=$rowSelImg['product_thumbnail_4'];
$productThumbnail5=$rowSelImg['product_thumbnail_5'];
for($i=1;$i<6;$i++)
{
$imgThumb[$i]=$rowSelImg['product_thumbnail_'.$i];
$imgOriginal[$i]=$rowSelImg['product_image_'.$i];
}
}
else
   {
   include_once "not_found.php";
   exit;
   }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
function showImage(img)
{
document.getElementById("divImageViewer").style.background="url("+img+") no-repeat";
document.getElementById("divImageViewer").style.backgroundPosition="center center";
//document.getElementById("divImageViewer").innerHTML="<img src="+img+">";
}
</script>
<style type="text/css">
.panel { border:1px solid #CCC; margin:0; padding:0; }
</style>
</head>
<body>
<table width="548" border="0" class="panel">
  <tr>
    <td width="500" height="500" id="divImageViewer" <?php
	if(isset($_GET['img']) && $_GET['img']!="")
	{
	$image=$_GET['img'];
	 echo $styleImageDefault="style='background:url(".$imgOriginal[$image].") no-repeat center center'";
	 }
	 else
	 {
	  $flag=0;
	  foreach($imgOriginal as $key => $value)
	   {
		 if(!empty($value) && $flag==0)
		 {
		 echo $styleImageDefault="style='background:url(".$imgOriginal[$key].") no-repeat center center'";
		  $flag=1;
        }
		}
	  }
	 ?>
   >&nbsp;
    </td>
  </tr>
  <tr>
    <td height="23">&nbsp;</td>
  </tr>
  <tr>
    <td>
    <?php
	if(isset($_GET['prod']) && $_GET['prod']!="")
	{
	?>
    <table width="100%" border="0">
      <tr>
      <td>
      <div  class="panel">
        <?php
		foreach($imgThumb as $key => $value)
		{
			if(!empty($value))
			echo "&nbsp;<input type=image src='".$value."' onClick=showImage('".$imgOriginal[$key]."')>";
         }
		}
        ?>
        </div>
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</body>
</html>